extension ObjectEx on Object {
  double get getDouble {
    if (this is double) {
      return this as double;
    } else if (this is String) {
      try {
        return double.parse(this as String);
      } catch (e) {
        return 0;
      }
    } else {
      return 0;
    }
  }
}

dynamic toDouble(dynamic obj) {
  if (obj == null) {
    return 0;
  }  else if (obj is double) {
    return obj;
  } else if (obj is int) {
    return obj;
  } else if (obj is String) {
    try {
      return double.parse(obj);
    } catch (e) {
      return 0.0;
    }
  } else {
    return 0.0;
  }
}

int toInt(dynamic obj) {
  if (obj == null) {
    return 0;
  }  else if (obj is int) {
    return obj;
  } else if (obj is double) {
    return obj.toInt();
  } else if (obj is String) {
    try {
      return int.parse(obj);
    } catch (e) {
      return 0;
    }
  } else {
    return 0;
  }
}